<?php
include('../../inc/global.inc');

$url="index.php";
$thepage=$_GET['page']?$_GET['page']:1;
$maxpage=20;
?>
<?php
//删除信息
if($_GET['del_act']){
mysql_query("delete from note where id='".$_GET['del_id']."'");
echo "<script>location='".$url."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">询价邮件&nbsp;&nbsp;<a href="javascript:window.location=window.location">刷新列表</a>&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
  <table width="95%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="5"></td>
    </tr>
  </table>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
<form method="get" action="index.php">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding:5px;line-height:25px;"><strong>搜索:</strong> 是否阅读:
        <select name="search_type">
	  <option value="">--选择--</option>
	  <option value="1">是</option>
	  <option value="0">否</option>
	  </select>&nbsp;&nbsp;
	  <input type="submit" value="搜索">
	  <input type="hidden" name="search_act" value="ok"></td>
    </tr>
</form>
  </table> 
  <table width="95%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="5"></td>
    </tr>
  </table>
  <?php 
if($_GET[search_act]){
$search_sql="where 1=1";
$search_sql=$search_sql." and is_read='$_GET[search_type]'";
echo $search_sql;
}
?>
<table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td width="8%" height="30" align="center" bgcolor="#8DA8CF">编号</td>
      <td width="26%" align="center" bgcolor="#8DA8CF">主题</td>
      <td width="14%" align="center" bgcolor="#8DA8CF">发送者</td>
      <td width="15%" align="center" bgcolor="#8DA8CF">接收者</td>
      <td width="16%" align="center" bgcolor="#8DA8CF">时间</td>
      <td width="8%" align="center" bgcolor="#8DA8CF">是否阅读</td>
      <td width="13%" align="center" bgcolor="#8DA8CF">管理</td>
    </tr>
<?php
$sql="select * from note ".$search_sql." order by id desc, is_read asc limit ".($thepage-1)*$maxpage.",$maxpage";
$rs=mysql_query($sql);
$i=1;
while($row=mysql_fetch_array($rs)){
$color=($i%2)?"#FFFFFF":"#eeeeee";
?>
    <tr bgcolor=<?=$color?>>
      <td height="25" align="center"><?=$i?></td>
	  <td align="center"><a href="<?=$row[n_web]?>" target="_blank"><?=$row[n_subject]?></a></td>
	  <td align="center"><?php
	  $m_rs=@mysql_query("select * from member where id='$row[from_id]'");
	  $m_row=@mysql_fetch_array($m_rs);
	  ?><?=$m_row[m_user]?></td>
	  <td align="center"><?php
	  $m_rs=@mysql_query("select * from member where id='$row[to_id]'");
	  $m_row=@mysql_fetch_array($m_rs);
	  ?><?=$m_row[m_user]?></td>
	  <td align="center"><?=$row['add_time']?></td>
	  <td align="center"><?php if($row[is_read]==1){echo "YES";}else{echo "<font color='red'>NO</font>";}?></td>
      <td align="center"><a href="index_modify.php?xg_id=<?=$row['id']?>">阅读</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="<?=$url?>?del_act=ok&del_id=<?=$row['id']?>" onClick="return del()">删除</a></td>
    </tr>
<?php
$i++;}
//分页参数
$totalrecord=mysql_num_rows(mysql_query("select * from note ".$search_sql));
$totalpage=ceil($totalrecord/$maxpage);
?>
<tr><form method="get" action="<?=$url?>?search_type=<?=$_GET[search_type]?>&search_act=ok">
   <td height="25" colspan="7" align="center" bgcolor="#FFFFFF">
<?php if($thepage>1){?>
   <a href="<?=$url?>?search_type=<?=$_GET[search_type]?>&search_act=ok">第一页</a>&nbsp;<a href="<?=$url?>?page=<?=$thepage-1?>"&search_type=<?=$_GET[search_type]?>&search_act=ok>上一页</a>&nbsp;
<?php }?>  
<?php if($thepage!=$totalpage&&$totalpage>1){?>
   <a href="<?=$url?>?page=<?=$thepage+1?>&search_type=<?=$_GET[search_type]?>&search_act=ok">下一页</a>&nbsp;<a href="<?=$url?>?page=<?=$totalpage?>&search_type=<?=$_GET[search_type]?>&search_act=ok">最后一页</a>&nbsp;
<?php }?>   
   【共<font color="red"><?=$totalrecord?></font>条记录】【每页<font color="red"><?=$maxpage?></font>条记录】【共<font color="red"><?=$totalpage?></font>页】<input type="text" name="page" size="3" onKeyUp="IsDigit(this);">&nbsp;<input type="submit" value="GO"></td></form>
</tr>
  </table>

</center>
</BODY>
</HTML>


<script language="javascript">
function IsDigit(obj) 
{ 
if(obj.value.replace(/[\d+]/ig,"").length>0) { 
  alert('请输入数字'); 
  document.getElementById(obj).value =""; 
} 
} 
</script>